<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>EFF Admin</title>
    <style type="text/css">
    #results
    {
        font-size:17px;
        margin:10px 10px 10px 0;    
    }
    .red{color:Red}
    .green{color:Green}
    </style>
    <script src="<%=ResolveUrl("~/Assets/Scripts/jquery-1.4.1.js")%>" type="text/javascript"></script>
    <script src="<%=ResolveUrl("~/Assets/Scripts/jquery.form.js")%>" type="text/javascript"></script>
    <%--<link href="<%=ResolveUrl("~/Assets/CSS/global.css")%>" rel="stylesheet" type="text/css" />--%>
<%--<link rel="stylesheet" type="" href="<%=ResolveUrl("~/Assets/CSS/style.css")%>" />--%>

		<!--                       CSS                       -->
	  
		<!-- Reset Stylesheet -->
		<link rel="stylesheet" href="<%=ResolveUrl("~/Assets/resources/css/reset.css")%>" type="text/css" media="screen" />
	  
		<!-- Main Stylesheet -->
		<link rel="stylesheet" href="<%=ResolveUrl("~/Assets/resources/css/style.css")%>" type="text/css" media="screen" />
		
		<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
		<link rel="stylesheet" href="<%=ResolveUrl("~/Assets/resources/css/invalid.css")%>" type="text/css" media="screen" />	
        <script type="text/javascript" src="<%=ResolveUrl("~/Assets/resources/scripts/simpla.jquery.configuration.js")%>"></script>
		
		<!-- Facebox jQuery Plugin -->
		<script type="text/javascript" src="<%=ResolveUrl("~/Assets/resources/scripts/facebox.js")%>"></script>
		
		<!-- jQuery WYSIWYG Plugin -->
</head>
<body id="login">
		
		<div id="login-wrapper" class="png_bg">
			<div id="login-top">
			
				<h1>EFF Admin</h1>
				<!-- Logo (221px width) -->
				<img id="logo" src="<%=ResolveUrl("~/Assets/resources/images/logo.png")%>" alt="logo" />
			</div> <!-- End #logn-top -->
			
			<div id="login-content">
				
				<form action="/Login/ManagementLogin">
				
					<div id="results" class="notification information png_bg">
						<div id="alert">
							Please enter your login details below.
						</div>
					</div>
					
					<p>
						<label>Email</label>
						<input class="text-input" type="text" name="email" id="email" />
					</p>
					<div class="clear"></div>
					<p>
						<label>Password</label>
						<input class="text-input" type="password" name="password" id="password" />
					</p>
					<div class="clear"></div>
					<p id="remember-password">
						<input type="checkbox" name="keep" />Remember me
					</p>
					<div class="clear"></div>
					<p>
						<input type="button" onclick="return DoAjaxSubmit(this);" value="Sign In" class="button" />
					</p>
					
				</form>
			</div> <!-- End #login-content -->
			
		</div> <!-- End #login-wrapper -->
		
  </body>
  <script type="text/javascript">
      function DoAjaxSubmit(btnClicked) {
          $("#results").removeClass("information");
          var form = $(btnClicked).parents('form');

          if ($("#email").val() == "" || $("#password").val() == "") {
              $("#alert").html("Please complete all fields.");
              $("#results").addClass("error");

              return false;
          }
          

          else {
              $("#alert").html("Authenticating.");
              $("#results").addClass("information");

              $.ajax({
                  type: "POST",
                  url: form.attr('action'), //'<%=ResolveUrl("~/register/go") %>',
                  data: form.serialize(),
                  error: function(xhr, status, error) {
                  },
                  success: function(response) {
                      if (response != null) {
                          if (!response.Successful) {
                              $("#alert").html("Invalid credentials.");
                              $("#results").addClass("error");
                              return false;
                          }
                          else {

                              $("#alert").html("Success!");
                              $("#results").addClass("success");
                              window.location = "/Management/Index";
                              return true;
                          }
                      }
                  }
              });
          }
          return false;
      }
    </script>
</html>